﻿<DocumentContent 
    x:Class="Poet.Views.DocumentView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:converters="clr-namespace:Poet.Converters"
    xmlns:views="clr-namespace:Poet.Views" Height="259" Width="875"
    x:Name="This">

    <DocumentContent.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="..\Resources\XamlStore.xaml" />
            </ResourceDictionary.MergedDictionaries>
            <converters:TitleConverter x:Key="TitleConverter"/>
        </ResourceDictionary>
    </DocumentContent.Resources>

    <DocumentContent.Title>
        <Binding Path="Title" Converter="{StaticResource TitleConverter}"/>
    </DocumentContent.Title>

    <DocumentContent.InputBindings>
        <KeyBinding Key="Escape" Command="ApplicationCommands.Close"/>
        <KeyBinding Key="X" Modifiers="Alt" Command="ApplicationCommands.Close"/>
        <KeyBinding Key="L" Modifiers="Ctrl" Command="ApplicationCommands.Print" CommandParameter="PageSetup"/>
        <KeyBinding Key="E" Modifiers="Ctrl" Command="ApplicationCommands.Properties" CommandParameter=":Encoding"/>
        <KeyBinding Key="R" Modifiers="Ctrl+Shift" Command="ApplicationCommands.Open" CommandParameter=":Encoding"/>
        <KeyBinding Key="R" Modifiers="Ctrl" Command="ApplicationCommands.Open" CommandParameter=":Reload"/>
        <KeyBinding Key="G" Modifiers="Ctrl" Command="ApplicationCommands.Find" CommandParameter="GoToLine"/>
        <KeyBinding Key="T" Modifiers="Ctrl" Command="ApplicationCommands.Find" CommandParameter="Translate"/>
        <KeyBinding Key="W" Modifiers="Ctrl" Command="ApplicationCommands.Find" CommandParameter="Search"/>
        <KeyBinding Key="F4" Command="ApplicationCommands.Properties" CommandParameter="About"/>
        <KeyBinding Key="F5" Command="ApplicationCommands.Properties" CommandParameter="SetAssotiations"/>
    </DocumentContent.InputBindings>

    <Grid>

        <Grid.ContextMenu>
            <ContextMenu ItemsSource="{StaticResource DocumentContextMenuItems}">
                <ContextMenu.Resources>
                    <ResourceDictionary>
                        <ResourceDictionary.MergedDictionaries>
                            <ResourceDictionary Source="..\Resources\MenuResources.xaml" />
                        </ResourceDictionary.MergedDictionaries>
                    </ResourceDictionary>
                </ContextMenu.Resources>
            </ContextMenu>
        </Grid.ContextMenu>

        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*" Name="Row2"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>

        <Menu
            Name="Menu"
            IsMainMenu="False"
            Visibility="{ViewModel ShowMenu, DefaultValue=False}"
            Background="{Binding ElementName=ToolBarTray, Path=Background}" 
            ItemsSource="{StaticResource DocumentMenuItems}">
            <Menu.Resources>
                <ResourceDictionary>
                    <ResourceDictionary.MergedDictionaries>
                        <ResourceDictionary Source="..\Resources\MenuResources.xaml" />
                    </ResourceDictionary.MergedDictionaries>
                </ResourceDictionary>
            </Menu.Resources>
        </Menu>

        <ToolBarTray 
            Grid.Row="1" 
            MinHeight="27" 
            Name="ToolBarTray" 
            Visibility="{ViewModel ShowToolBarTray, DefaultValue=False}">

            <ToolBarTray.Resources>
                <ResourceDictionary>
                    <ResourceDictionary.MergedDictionaries>
                        <ResourceDictionary Source="..\Resources\ToolBarTrayResources.xaml" />
                    </ResourceDictionary.MergedDictionaries>
                </ResourceDictionary>
            </ToolBarTray.Resources>

            <ToolBarTray.ContextMenu>
                <ContextMenu Name="ContextMenu" ItemsSource="{VisibilityMenuItems SourceName=ToolBarTray, SourcePropertyName=ToolBars, StyleStaticKey=CheckableItemStyle}"/>
            </ToolBarTray.ContextMenu>

        </ToolBarTray>

        <views:SplitableTextEditorView Grid.Row="2" DataContext="{Binding TextEditorViewModel}" x:Name="SplitableTextEditor"/>

        <StatusBar
            Grid.Row="3" 
            MinHeight="22"
            ItemsSource="{StaticResource StatusBarItems}"
            Background="{Binding ElementName=Menu, Path=Background}"
            Visibility="{ViewModel ShowStatusBar, DefaultValue=False}"
            ToolTip="{StaticResource StatusBarToolTip}"
            ToolTipService.ShowDuration="32000000"
            ToolTipService.IsEnabled="{ViewModel ShowStatusBarToolTip, DefaultValue=True}">
            <StatusBar.Resources>
                <Style TargetType="{x:Type TextBlock}" BasedOn="{StaticResource StatusBarTextBlockStyle}">
                    <Setter Property="DataContext" Value="{Binding}"/>
                </Style>
            </StatusBar.Resources>
        </StatusBar>

    </Grid>

</DocumentContent>
